<?php
class Login extends MY_Controller{
	
	function __construct(){
		parent::__construct();
	}
	
	function index(){
		$data['message'] = $this->session->flashdata('message');
		$this->_view('login',$data);
	}
	
	function dologin(){
		$login = $this->input->post('login',true);
		$redirectURL = urldecode($_REQUEST['redirectURL']);
		$redirectLogin = $redirectURL?'login?redirectURL='.$redirectURL:'login';
		
		if($login){
			$s_captcha = $this->session->userdata('captcha');
			$captcha = $login['captcha'];
			if($s_captcha != strtoupper($captcha)){
				$this->session->set_flashdata('message','验证码输入错误！');
				redirect($redirectLogin);
			}else if($login['username']!='litong' || $login['password']!='111111'){
				$this->session->set_flashdata('message','用户名或密码输入错误！');
				redirect($redirectLogin);
			}
			$this->session->set_userdata('login',$login);
			if($redirectURL){
				redirect($redirectURL);
			}else{
				redirect('manager/main/index');
			}
		}else{
			redirect($redirectLogin);
		}
	}
	function logout(){
		$this->session->unset_userdata('login');
		redirect('login');
	}
}
?>